import {Component} from '@angular/core';
import {
  CdkDragDrop,
  moveItemInArray,
  transferArrayItem,
  CdkDrag,
  CdkDropList,
} from '@angular/cdk/drag-drop';


@Component({
  selector: 'app-home',
  templateUrl: './home.component.html',
  styleUrls: ['./home.component.less']
})
export class HomeComponent {
  todo = [
    {
      title: '这是任务1',
      content: '这是content1'
    },
    {
      title: '这是任务2',
      content: '这是content2'
    }
  ]
  inProgress = [
    {
      title: '这是任务3',
      content: '这是content3'
    }
  ]
  test = [
    {
      title: '这是任务4',
      content: '这是content4'
    }
  ]
  review = [
    {
      title: '这是任务5',
      content: '这是content5'
    }
  ]
  done = [
    {
      title: '这是任务6',
      content: '这是content6'
    },
    {
      title: '这是任务7',
      content: '这是content7'
    }
  ]
  invalid = [
    {
      title: '这是任务8',
      content: '这是content8'
    }
  ]

  drop(event: CdkDragDrop<{ title: string; content: string; }[]>) {
    if (event.previousContainer === event.container) {
      moveItemInArray(event.container.data, event.previousIndex, event.currentIndex);
    } else {
      transferArrayItem(
        event.previousContainer.data,
        event.container.data,
        event.previousIndex,
        event.currentIndex,
      );
    }
    console.log(this.todo, this.inProgress, this.review, this.test, this.done, this.invalid)
  }

}
